package simplecoder.domain;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

public abstract class Clazz {

	protected Pojo pojo;
	protected String name;
	protected String packName;
	protected Module module;
	protected Map<String, Object> params;
	
	public void init(Module module){
		this.module = module;
		this.pojo = module.getPojo();
		this.name = pojo.getName()+getSuffix();
		this.packName = getPackName(pojo.getPackName());
		params = new HashMap<String, Object>();
		params.put("name", name);
		params.put("packName", packName);
		params.put("pojoPackName", pojo.getPackName());
		params.put("pojoName", pojo.getName());
		params.put("pojoClassName", pojo.getClassName());
		params.put("pojoInstanceName", StringUtils.uncapitalize(pojo.getName()));
		
		init();
	}
	
	protected abstract void init();
	
	public abstract String getPackName(String pojoPackName);
	
	public abstract String getSuffix();
	
//	public void setClassName(String className) {
//		this.className = className;
//	}
	
	public Map<String, Object> getParams() {
		return params;
	}
	
	public String getName() {
		return name;
	}
	
	public String getPackName(){
		return packName;
	}
	
	public String getClassName(){
		return packName+"."+name;
	}
}
